<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>02_CSS选择器</title>
    <style>
        /*标签选择器*/
        h4 {color: red;}
        /*id选择器*/
        #d1 {
            width: 100px;
            height: 100px;
            background-color: cyan;
        }
        /*类选择器*/
        .msg {color: white}
        .error {background-color: red}
        .success {background-color: green}
        /*并列选择器
        hover鼠标悬停显示的颜色*/
        #d1:hover{background-color: orange}
        /*群组选择器*/
        h4,#d1,.error {border: 5px solid black}
        /*伪类选择器*/
        a:link {color: gray}
        a:visited {color: green}
        a:hover {color: orange}
        a:active {color: red}
        /*属性选择器*/
        input[name="uname"]{
            background-color: yellow;
        }
        /*通用选择器*/
        *{
            font-style: italic;
        }
        /*后代选择器*/
        #d2 span{
            background-color: pink;
        }
        /*直接子代选择器*/
        #d2>div>p>span {
            color: green;
        }
    </style>
</head>
<body>
    <div id="d1">我是div</div>
    <div>我是div</div>
    <p>我是段落</p>
    <p>我是段落</p>
    <h4>我是标题</h4>
    <h4>我是标题</h4>
    <hr>
    <span class="error msg">用户名不能为空</span>
    <span class="error msg">密码不一致</span>
    <span class="error msg">身份验证失败</span>
    <span class="success msg">手机号格式正确</span>
    <span class="success msg">邮箱格式正确</span>
    <hr>
    <a href="https://www.baidu.com">超链接1</a>
    <a href="abc">超链接2</a>
    <hr>
    <input type="text" name="uname">
    <input type="text" name="nickname">
    <select name="uname">
        <option value="1"></option>
        <option value="2"></option>
    </select>
    <hr>
    <div id="d2">
        <span>111</span>
        <div>
            <span>222</span>
            <p>测试文字</p>
            <p>我是<span>333</span>段落</p>
        </div>
        <span>444</span>
    </div>




</body>
</html>